﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DXApplicationTangche.UC.生产计划.生产批生产.service;
using DXApplicationTangche.UC.项目成果管理;
using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.UC.生产计划.生产批生产.model;
using DXApplicationTangche.UC.订单一览新.订单预览新;
using DXApplicationTangche.UC.订单一览新.订单预览新.service;
using DXApplicationTangche.UC.样品管理.样品订单预览;
using DXApplicationTangche.UC.生产计划.编排生产批.service;

namespace DXApplicationTangche.UC.生产计划.生产批生产
{
    public partial class Form已投产 : DevExpress.XtraEditors.XtraForm
    {
        private String code { get; set; }
        private List<DTO生产批生产> DTO生产批s = new List<DTO生产批生产>();
        public Form已投产(String code)
        {
            InitializeComponent();
            this.code = code;
            try
            {
                //接口查询，尺寸清洗
                this.DTO生产批s = new 生产批生产Model().build清洗尺寸(生产批生产Service.get已投产一览(this.code));
            }
            catch 
            {
                MessageBox.Show("无投产信息");
            }
            this.gridControl生产批.DataSource = this.DTO生产批s;
            this.gridView生产批.ExpandAllGroups();
        }

        private void 查看工序ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new Form查看工序(
                FunctionHelper.GetgridViewValue(
                    this.gridView生产批,
                    this.gridView生产批.FocusedRowHandle,
                    "batchNo"
                    )
                ).ShowDialog();
        }

        private void 查看订单ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                String orderId = FunctionHelper.GetgridViewValue(
                        this.gridView生产批, 
                        this.gridView生产批.FocusedRowHandle, 
                        "orderId");
                String batchNo = FunctionHelper.GetgridViewValue(
                        this.gridView生产批,
                        this.gridView生产批.FocusedRowHandle,
                        "batchNo");
                DTO生产批 dTO生产批 = 编排生产批Service.getWIPBatchByBatchNo(batchNo);
                if (String.IsNullOrEmpty(dTO生产批.orderId))
                {
                    return;
                }
                if ("48".Equals(订单预览新Service.get订单预览(orderId).shopId))
                {
                    new Form样品订单预览新(dTO生产批).ShowDialog();
                }
                else
                {
                    new Form订单预览新(dTO生产批).ShowDialog();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}